home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CRON_1 / STANDARD / TRAP_UTI.C < prev    next >
C/C++ Source or Header  |  1991-06-10  |  970b  |  62 lines

  1. #include "Trap Util.h"
  2.  
  3.  
  4. /*    All of this code comes directly from IM VI pg. 3-8. */
  5.  
  6.  
  7. #define _Unimplemented    0xA89F
  8. #define _InitGraf        0xA86E
  9.  
  10.  
  11. int                        NumToolboxTraps(void);
  12. TrapType                GetTrapType(int theTrap);
  13. Boolean                    TrapAvailable(int theTrap);
  14.  
  15.  
  16.  
  17.  
  18. int NumToolboxTraps() {
  19.     int                        NumToolboxTraps;
  20.     
  21.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
  22.         NumToolboxTraps = 0x200;
  23.     else
  24.         NumToolboxTraps = 0x400;
  25.         
  26.     return (NumToolboxTraps);
  27. }
  28.  
  29.  
  30. TrapType GetTrapType(theTrap)
  31. int                        theTrap;
  32. {
  33.     TrapType                tType;
  34.     
  35.     if ((theTrap & 0x0800) > 0)
  36.         tType = ToolTrap;
  37.     else
  38.         tType = OSTrap;
  39.     
  40.     return (tType);
  41. }
  42.  
  43.  
  44. Boolean TrapAvailable(theTrap)
  45. int                        theTrap;
  46. {
  47.     TrapType                tType;
  48.     
  49.     tType = GetTrapType(theTrap);
  50.     
  51.     if (tType == ToolTrap) {
  52.         
  53.         theTrap &= 0x07FF;
  54.         if (theTrap >= NumToolboxTraps())
  55.             theTrap = _Unimplemented;
  56.     }
  57.     
  58.     return (NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap));
  59. }
  60.  
  61.  
  62.